﻿@inject IStringLocalizer<SelectTrees> Localizer

<ValidateForm Model="BindModel">
    <div class="row g-3">
        <div class="col-12 col-sm-6">
            <SelectTree TValue="string" @bind-Value="BindModel.Text" ShowIcon="true" Items="BindItems" />
        </div>
        <div class="col-12 col-sm-6 align-self-end">
            <Button ButtonType="ButtonType.Submit">@Localizer["SelectTreesClientValidationButtonText"]</Button>
        </div>
    </div>
</ValidateForm>

@code {
    [NotNull]
    private TreeFoo? Model { get; set; }

    private TreeFoo BindModel { get; set; } = new TreeFoo();

    [NotNull]
    private List<TreeViewItem<string>>? BindItems { get; set; }

    /// <summary>
    /// OnInitialized
    /// </summary>
    protected override void OnInitialized()
    {
        Model = new TreeFoo()
        {
            Text = "Sub Menu Three",
            Id = "1090",
            ParentId = "1050",
            Icon = "fa-solid fa-font-awesome",
            IsActive = true
        };

        BindItems = new List<TreeViewItem<string>>()
        {
            new TreeViewItem<string>("目录一")
            {
                Text ="目录一",
                Icon = "fa-solid fa-folder",
                ExpandIcon = "fa-solid fa-folder-open",
                Items = new List<TreeViewItem<string>>()
                {
                    new TreeViewItem<string>("子目录一")
                    {
                        Text ="子目录一",
                        Icon = "fa-solid fa-folder",
                        ExpandIcon = "fa-solid fa-folder-open",
                        Items = new List<TreeViewItem<string>>()
                        {
                            new TreeViewItem<string>("文件一") { Text = "文件一", Icon = "fa-solid fa-file", IsActive = true },
                            new TreeViewItem<string>("文件二") { Text = "文件二", Icon = "fa-solid fa-file" }
                        }
                    }
                }
            }
        };
    }
}
